import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path:"/login",
    name:"login",
    component:()=>import('../views/login/Login.vue')
  },
  {
    path:"/",
    name:"index",
    component:()=>import('../views/home/Index.vue'),
    children:[
      {
        path:"home",
        name:"home",
        component:()=>import('../views/home/Home.vue')
      },
      {
        path:"shop/list",
        name:"list",
        component:()=>import('../views/shop/List.vue')
      },
      {
        path:"shop/group",
        name:"group",
        component:()=>import('../views/shop/Group.vue')
      },
      {
        path:"shop/classify",
        name:"classify",
        component:()=>import('../views/shop/Classify.vue')
      },
      {
        path:"shop/brand",
        name:"brand",
        component:()=>import('../views/shop/Brand.vue')
      },
      {
        path:"shop/setting",
        name:"setting",
        component:()=>import('../views/shop/Setting.vue')
      },
      {
        path:"order/overview",
        name:"overview",
        component:()=>import('../views/order/Overview.vue')
      },
      {
        path:"order/status",
        name:"status",
        component:()=>import('../views/order/Status.vue')
      },
      {
        path:"order/protection",
        name:"protection",
        component:()=>import('../views/order/Protection.vue')
      },
      {
        path:"order/tools",
        name:"tools",
        component:()=>import('../views/order/Tools.vue')
      },
      {
        path:"finance/integral",
        name:"integral",
        component:()=>import('../views/finance/Integral.vue')
      },
      {
        path:"finance/amount",
        name:"amount",
        component:()=>import('../views/finance/Amount.vue')
      },
      {
        path:"finance/bill",
        name:"bill",
        component:()=>import('../views/finance/Bill.vue')
      },
      {
        path:"finance/topup",
        name:"tuoup",
        component:()=>import('../views/finance/TopUp.vue')
      },
      {
        path:"offers/basic",
        name:"basic",
        redirect:'offers/basic/lijian',
        component:()=>import('../views/offers/Basic.vue'),
        children:[
          {
            path:'lijian',
            name:'lijian',
            component:()=>import('../views/offers/LiJian.vue')
          },
          {
            path:'baoyou',
            name:'baoyou',
            component:()=>import('../views/offers/BaoYou.vue')
          },
          {
            path:'chongzhi',
            name:'chongzhi',
            component:()=>import('../views/offers/ChongZhi.vue')
          }
        ]
      },
      {
        path:"offers/coupons",
        redirect:'offers/coupons/mingxi',
        name:"coupons",
        component:()=>import('../views/offers/Coupons.vue'),
        children:[
          {
            path:'mingxi',
            name:'mingxi',
            component:()=>import('../views/offers/MingXi.vue'),
          },
          {
            path:'jilu',
            name:'jilu',
            component:()=>import('../views/offers/JiLu.vue'),
          },          {
            path:'fenlei',
            name:'fenlei',
            component:()=>import('../views/offers/FenLei.vue'),
          },          
          {
            path:'set',
            name:'set',
            component:()=>import('../views/offers/Set.vue'),
          }
        ]
      },
      {
        path:"member/vlist",
        name:"vlist",
        component:()=>import("../views/member/Vlist.vue")
      },
      {
        path:"member/voverview",
        name:"voverview",
        component:()=>import("../views/member/Voverview.vue")
      },
      // 会员详情
      {
        path:"member/vlistdetail",
        name:"vlistdetail",
        component:()=>import("../views/member/Vlist/Vlistdetail.vue")
      },
      {
        path:"member/level",
        name:"level",
        component:()=>import("../views/member/Level.vue")
      },
      {
        path:"member/vgroup",
        name:"vgroup",
        component:()=>import("../views/member/Vgroup.vue")
      },
      {
        path:"active/seconds",
        name:"seconds",
        component:()=>import("../views/active/Seconds.vue")
      },
      {
        path:"member/setlevel",
        name:"setlevel",
        component:()=>import("../views/member/Level/Edit.vue")
      },
      {
        path:"member/vgroup",
        name:"vgroup",
        component:()=>import("../views/member/Vgroup.vue")
      },
      {
        path:"member/addvips",
        name:"addvips",
        component:()=>import("../views/member/Vgroup/Addvips.vue")
      },
      {
        path:"active/seconds/addseconds",
        name:"addseconds",
        component:()=>import("../views/active/Seconds/AddSecond.vue")
      },
      {
        path:"active/seconds/addhuicshops",
        name:"addhuicshops",
        component:()=>import("../views/active/Seconds/Addhuicshops.vue")
      },
      {
        path:"active/spell",
        name:"spell",
        component:()=>import("../views/active/Spell.vue")
      },
      {
        path:"active/spell/spellstatedetail",
        name:"spellstatedetail",
        component:()=>import("../views/active/Spell/Spellstatedetail.vue")
      },
      {
        path:"active/spell/addspellshop",
        name:"addspellshop",
        component:()=>import("../views/active/Spell/Addspellshop.vue")
      },
      {
        path:"point/shoplist",
        name:"shoplist",
        component:()=>import("../views/point/ShopList.vue")
      },
      {
        path:"point/swiper",
        name:"swiper",
        component:()=>import("../views/point/Swiper.vue")
      },
      {
        path:"point/sort",
        name:"sort",
        component:()=>import("../views/point/Sort.vue")
      },
      {
        path:"point/state",
        name:"state",
        component:()=>import("../views/point/State.vue")
      },
      {
        path:"limits/store",
        name:"store",
        component:()=>import("../views/limits/Store.vue"),
        children:[
          {
            path:"list",
            name:"Storelist",
            component:()=>import("../views/limits/StoreList.vue")
          },
          {
            path:"addstore",
            name:"addstore",
            component:()=>import("../views/limits/AddStore.vue")
          }
        ]
      },
      {
        path:"limits/set/store",
        name:'setStore',
        component:()=>import('../views/limits/SetStore.vue')
      },
      {
        path:"limits/admin",
        name:"admin",
        component:()=>import("../views/limits/Admin.vue"),
        children:[
          {
            "path":'list',
            "name":'adminlist',
            component:()=>import('../views/limits/AdminList.vue')
          },
          {
            "path":'addAdmin',
            "name":'addAdmin',
            component:()=>import('../views/limits/Addadmin.vue')
          }
        ]
      },
      {
        path:"limits/setAdmin",
        name:"setAdmin",
        component:()=>import("../views/limits/SetAdmin.vue")
      },
      {
        path:"limits/withdraw",
        name:"withdraw",
        component:()=>import("../views/limits/Withdraw.vue")
      },
      {
        path:"limits/role",
        name:"role",
        component:()=>import("../views/limits/Role.vue")
      },
      {
        path:"limits/addrole",
        name:"addrole",
        component:()=>import("../views/limits/AddRole.vue")
      },
      {
        path:"evaluate",
        name:"evaluate",
        component:()=>import("../views/evaluate/Evaluate.vue")
      },
      {
        path:"evaluate/detailevaluate",
        name:"detailevaluate",
        component:()=>import("../views/evaluate/Evaluate/DetailEvaluate.vue")
      },
      {
        path:"mesage/idea",
        name:"idea",
        component:()=>import("../views/mesage/Idea.vue")
      },
      {
        path:"mesage/coope",
        name:"coope",
        component:()=>import("../views/mesage/Coope.vue")
      },
      {
        path:"mesage/problem",
        name:"problem",
        component:()=>import("../views/mesage/Problem.vue")
      },

      // 宝霞
      {
        path:"home/swiper",
        name:'homeSwiper',
        component:()=>import("../views/home/HomeSwi.vue")
      },
      {
        path:"home/navIcon",
        name:'navIcon',
        component:()=>import("../views/home/NavIcon.vue")
      },
      {
        path:"home/shopRe",
        name:'shopRe',
        component:()=>import("../views/home/ShopRe.vue")
      },
      {
        path:"home/announcement",
        name:'announcement',
        component:()=>import("../views/home/Announcement.vue")
      },
      {
        path:"home/adress",
        name:'adress',
        component:()=>import("../views/home/Adress.vue")
      },
      {
        path:"home/homeSort",
        name:'homeSort',
        component:()=>import("../views/home/HomeSort.vue")
      },
      {
        path:"home/addShop",
        name:'addShop',
        component:()=>import("../views/home/AddShop.vue")
      },
      {
        path:"limits/listdetail",
        name:"listdetail",
        component:()=>import("../views/limits/ListDetail.vue")
      },
      // 赵文宇
      
      {
        path:"shop/listadd/:id",
        name:"listadd",
        component:()=>import("../views/shop/Listadd.vue")
      },
      {
        path:"shop/groupadd/:id",
        name:"groupadd",
        component:()=>import("../views/shop/Groupadd.vue")
      },
      {
        path:"shop/brandadd/:id",
        name:"branddd",
        component:()=>import("../views/shop/Brandadd.vue")
      },
      {
        path:"order/status/detail/:id",
        name:"statusDetail",
        component:()=>import("../views/order/StatusDetail.vue")
      },
      {
        path:"order/protection/detail/:id",
        name:"ProtectionDetail",
        component:()=>import("../views/order/ProtectionDetail.vue")
      },
    ]
  }
  
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

router.beforeEach((to,from,next)=>{
  // console.log('beforEach',to)
  const token = localStorage.getItem('token')
  if(!token && to.path!='/login'){
    next('/login')
  }else{
    next()
  }
})
export default router
